package com.zhan.utils;

import java.util.Map;

/**
 * @author 白尚兵
 * @date 2019/9/6 11:36
 **/
public class MyExceptionUtil {
    public static void throwErr(String fieldName, String... values) {
        throw new RuntimeException(fieldName + "取值错误，取值范围：[" + MyStringUtils.concat(",", values) + "]!");
    }

    public static void throwErrMessage(String errMessage) {
        throw new RuntimeException(errMessage);
    }

    public static void throwErrMessage(String errMessage, String... params) {
        throw new RuntimeException(errMessage + ";参数：[" + MyStringUtils.concat(",", params) + "]!");
    }

    public static void throwExistsErr(Map<String, Object> columnMap) {
        StringBuilder sb = new StringBuilder();
        for (String column : columnMap.keySet()) {
            sb.append(",").append(column).append("=").append(columnMap.get(column));
        }
        String mes = sb.substring(1);
        throwErrMessage("[" + mes + "]已存在！");
    }
}
